<?php
  $dest = "";
  if(isset($_REQUEST["dest"])){
   $dest = $_REQUEST["dest"];
  }else{
   $dest='images/'.$_FILES['file']['name'];
  }
  $file_name=$_FILES['file']['name'];
  $extent_file="gif|jpg|png";
  $pattern='#.+\.(gif|jpg|png)$#i';
  if(preg_match($pattern,$file_name)==1){
      $file_type=true;
  }else{
      $file_type=false;
  }
  if($file_type==true){
      $source=$_FILES['file']['tmp_name'];
      if(copy($source,$dest)==true){
      $flag=true;
      echo 'Upload thành công';
      }else{
      $flag=false;
      echo 'Upload thất bại';
      }
  }
?>